import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 节点管理信息 */
export interface KnowledgeNode {
  id: number // 编号
  knowledgeId?: number // 知识库ID
  parentId?: number // 父节点ID
  name?: string // 标题
  description?: string // 描述
  keyFeatures?: string // 关键特征
  tags?: string // 标签
  sort?: number // 排序
  status?: number // 状态
}

// 节点管理 API
export const KnowledgeNodeApi = {
  // 查询节点管理分页
  getKnowledgeNodePage: async (params: any) => {
    return await request.get({ url: `/school/knowledge-node/page`, params })
  },

  // 查询节点列表
  getKnowledgeNodeList: async (params: any) => {
    return await request.get({ url: `/school/knowledge-node/list`, params })
  },

  // 查询节点列表
  getSimpleNodeList: async (params: any) => {
    return await request.get({ url: `/school/knowledge-node/simple-list`, params })
  },

  // 查询节点管理详情
  getKnowledgeNode: async (id: number) => {
    return await request.get({ url: `/school/knowledge-node/get?id=` + id })
  },

  // 新增节点管理
  createKnowledgeNode: async (data: KnowledgeNode) => {
    return await request.post({ url: `/school/knowledge-node/create`, data })
  },

  // 修改节点管理
  updateKnowledgeNode: async (data: KnowledgeNode) => {
    return await request.put({ url: `/school/knowledge-node/update`, data })
  },

  // 删除节点管理
  deleteKnowledgeNode: async (id: number) => {
    return await request.delete({ url: `/school/knowledge-node/delete?id=` + id })
  },

  /** 批量删除节点管理 */
  deleteKnowledgeNodeList: async (ids: number[]) => {
    return await request.delete({ url: `/school/knowledge-node/delete-list?ids=${ids.join(',')}` })
  },

  // 导出节点管理 Excel
  exportKnowledgeNode: async (params) => {
    return await request.download({ url: `/school/knowledge-node/export-excel`, params })
  }
}
